home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / dpmigcc5.zip / RSX / SOURCE / PROCESS.H < prev    next >
C/C++ Source or Header  |  1994-12-12  |  7KB  |  210 lines

  1. /* Copyright    Rainer Schnitker 92,93 */
  2.  
  3. #ifndef _RSX_PROCESS_H
  4. #define _RSX_PROCESS_H
  5.  
  6. #define N_SIGA        30        /* signal actions per process */
  7. #define N_FILES     40        /* open files per process */
  8. #define N_FD         2        /* bits field for close_on_exec */
  9. #define RSX_NFILES 100        /* RSX files for all processes */
  10.  
  11. #define DPMI_PRG_DATA 60*1024L*1024L
  12. #define DPMI_PRG_ROOM 64*1024L*1024L
  13.  
  14. /* emx swawnve */
  15. #define P_WAIT        0
  16. #define P_NOWAIT    1
  17. #define P_OVERLAY    2
  18. #define P_DEBUG     3
  19. #define P_SESSION    4
  20. #define P_DETACH    5
  21. #define P_PM        6
  22.  
  23. /* process status */
  24. #define PS_EMPTY    0    /* free process */
  25. #define PS_ZOMBIE    1    /* process exit, wait for father wait() */
  26. #define PS_RUN        2    /* process running */
  27. #define PS_STOP     3    /* process stopped */
  28. #define PS_WAIT     4    /* process is waiting */
  29.  
  30. /* process flags */
  31. #define PF_DEBUG    1    /* process debugged by ptrace */
  32. #define PF_MATH_USED    2    /* 387 state saving */
  33. #define PF_TERMIO    4    /* termio used */
  34. #define PF_WAIT_WAIT    8    /* wait for father wait() */
  35. #define PF_COMPRESS    16    /* compress memory for djgpp-system() call */
  36. #define PF_SPAWN_ASYNC    32    /* async spawn */
  37. #define PF_EMX_FILE    64    /* emx program */
  38. #define PF_DJGPP_FILE    128    /* djgpp program */
  39. #define PF_EXTENDER    256    /* dos extender process */
  40. #define PF_USEDPMI10    512    /* uses DPMI 1.0 paging, etc */
  41. #define PF_TNT_FILE    1024    /* TNT executable */
  42.  
  43. struct fpu_reg {
  44.     char sign;
  45.     char tag;
  46.     short align_fill_gcc;
  47.     long exp;
  48.     unsigned long sigl;
  49.     unsigned long sigh;
  50. };
  51.  
  52. union i387_union {
  53.     struct i387_hard_struct {
  54.         long    cwd;
  55.         long    swd;
  56.         long    twd;
  57.         long    fip;
  58.         long    fcs;
  59.         long    foo;
  60.         long    fos;
  61.         long    st_space[20];
  62.     } hard;
  63.     struct i387_soft_struct {
  64.         long    cwd;
  65.         long    swd;
  66.         long    twd;
  67.         long    fip;
  68.         long    fcs;
  69.         long    foo;
  70.         long    fos;
  71.         long    top;
  72.         struct fpu_reg    regs[8];
  73.         long res1 ;
  74.         long res2 ;
  75.         long res3 ;
  76.     } soft;
  77. };
  78.  
  79. #include "SIGNALS.H"
  80. #include "FS.H"
  81.  
  82. typedef struct p_tab
  83. {
  84.        REG386  regs;        /* process registers */
  85.     unsigned long  sig_raised;        /* signal raised y/n  (bits) */
  86.     unsigned long  sig_blocked;     /* signal en/disabled (bits) */
  87.     unsigned long  kstack;        /* kernel stack */
  88.  struct sigaction  sigaction[N_SIGA];    /* signal action */
  89.      struct p_tab  *pptr;        /* pointer to org. parent */
  90.      struct p_tab  *cptr;        /* pointer to last child */
  91.          UINT  pid;         /* process id */
  92.          UINT  p_status;        /* process status */
  93.          UINT  p_flags;        /* process flags */
  94.          UINT  wait_return;     /* return value for wait() */
  95.          UINT  code32sel;        /* code selector */
  96.          UINT  data32sel;        /* data selector */
  97.     unsigned long  membytes;        /* memory for process */
  98.     unsigned long  memhandle;        /* dpmi handle for memory block */
  99.     unsigned long  memaddress;        /* lin. address of memory block */
  100.     unsigned long  text_start;        /* first text address */
  101.     unsigned long  text_end;        /* last text address */
  102.     unsigned long  data_start;        /* first data address */
  103.     unsigned long  data_end;        /* last data address */
  104.     unsigned long  bss_start;        /* first bss address */
  105.     unsigned long  bss_end;        /* last bss address */
  106.          long  filehandle;        /* swapper file handle (dpmi 1.0) */
  107.     unsigned long  text_off;        /* offset text in file */
  108.     unsigned long  data_off;        /* offset data in file */
  109.     unsigned long  stacksize;        /* stack size */
  110.     unsigned long  stack_top;        /* stack top address */
  111.     unsigned long  stack_down;        /* stack bottom address */
  112.     unsigned long  stackp32;        /* stackpointer at prg start */
  113.     unsigned long  init_brk;        /* first brk value */
  114.     unsigned long  brk_value;        /* current brk value */
  115.     unsigned long  entry;        /* prg entry */
  116.     unsigned long  pagefree;        /* free memory in current page */
  117.     unsigned long  uflags;        /* uflags bits */
  118.     unsigned long  options;        /* options bits */
  119.     unsigned long  time_tic;        /* clock at start */
  120.     unsigned long  time_alarm;        /* alarm time */
  121.     struct file *  filp[N_FILES];    /* file descriptors */
  122.     p_fdset       close_on_exec;    /* (bits) */
  123.     union i387_union npx;
  124. } NEWPROCESS ;
  125.  
  126. typedef struct
  127. {
  128.     unsigned long  arg_off;
  129.     unsigned long  env_off;
  130.     unsigned long  fname_off;
  131.     unsigned short arg_sel;
  132.     unsigned short env_sel;
  133.     unsigned short fname_sel;
  134.     unsigned short arg_count;
  135.     unsigned short arg_size;
  136.     unsigned short env_count;
  137.     unsigned short env_size;
  138.     unsigned short mode;
  139. } PROCESS_ENV ;
  140.  
  141. #define EAX (npz->regs.eax)
  142. #define EBX (npz->regs.ebx)
  143. #define ECX (npz->regs.ecx)
  144. #define EDX (npz->regs.edx)
  145. #define ESI (npz->regs.esi)
  146. #define EDI (npz->regs.edi)
  147. #define EBP (npz->regs.ebp)
  148. #define ESP (npz->regs.esp)
  149. #define EIP (npz->regs.eip)
  150. #define ERR (npz->regs.err)
  151. #define ESPORG (npz->regs.esporg)
  152. #define EFLAGS (npz->regs.eflags)
  153. #define FAULTNO ((WORD)(npz->regs.faultno))
  154. #define CS  ((WORD)(npz->regs.cs))
  155. #define DS  ((WORD)(npz->regs.ds))
  156. #define ES  ((WORD)(npz->regs.es))
  157. #define SS  ((WORD)(npz->regs.ss))
  158. #define FS  ((WORD)(npz->regs.fs))
  159. #define GS  ((WORD)(npz->regs.gs))
  160.  
  161. #define AX (* (WORD *) & npz->regs.eax)
  162. #define BX (* (WORD *) & npz->regs.ebx)
  163. #define CX (* (WORD *) & npz->regs.ecx)
  164. #define DX (* (WORD *) & npz->regs.edx)
  165. #define SI (* (WORD *) & npz->regs.esi)
  166. #define DI (* (WORD *) & npz->regs.edi)
  167. #define BP (* (WORD *) & npz->regs.ebp)
  168. #define SP (* (WORD *) & npz->regs.esp)
  169. #define IP (* (WORD *) & npz->regs.eip)
  170. #define FLAGS (* (WORD *) & npz->regs.eflags)
  171.  
  172. #define AH (* ((BYTE *) (&npz->regs.eax) + 1))
  173. #define BH (* ((BYTE *) (&npz->regs.ebx) + 1))
  174. #define CH (* ((BYTE *) (&npz->regs.ecx) + 1))
  175. #define DH (* ((BYTE *) (&npz->regs.edx) + 1))
  176.  
  177. #define AL (* (BYTE *) &npz->regs.eax)
  178. #define BL (* (BYTE *) &npz->regs.ebx)
  179. #define CL (* (BYTE *) &npz->regs.ecx)
  180. #define DL (* (BYTE *) &npz->regs.edx)
  181.  
  182. #define N_PRZ    8
  183. #define RSX_PROCESS    process[0]
  184. #define FIRST_PROCESS    process[1]
  185. #define LAST_PROCESS    process[N_PRZ]
  186. extern NEWPROCESS process[N_PRZ+1] ;
  187. extern NEWPROCESS *npz;            /* current running process */
  188. extern unsigned current_pid;
  189.  
  190. /* process.c functions */
  191. int    send_signal ( NEWPROCESS *, int );
  192. void    switch_context(NEWPROCESS *p);
  193. int    schedule(void);
  194. void    init_this_process ( void );
  195. int    verify_illegal ( NEWPROCESS *, DWORD, DWORD );
  196. int    verify_illegal_write ( NEWPROCESS *, DWORD, DWORD );
  197. NEWPROCESS * find_process ( unsigned );
  198. unsigned sys_wait ( unsigned * );
  199. int    sys_waitpid(int, unsigned *);
  200. void    free_process ( NEWPROCESS * );
  201. void    clean_processtable( NEWPROCESS * );
  202. int    realmode_prg ( char *, char **, char ** );
  203. int    sys_fork ( void );
  204. int    exec32 ( unsigned int, char *, int, char **, int, char **);
  205. void    shut_down ( int );
  206. DWORD    getmem ( DWORD ,NEWPROCESS *);
  207. int    do_exit4c ( int );
  208.  
  209. #endif /* _RSX_PROCESS_H */
  210.